﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;

namespace SES.CMS.AdminCP.PageUC
{
    public partial class ucListProductOrigin : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            grvXuatXuDataSource();
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx?Page=ProductOrigin");
        }

        protected void grvXuatXu_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

            new cmsXuatXuBL().Delete(new cmsXuatXuDO { XuatXuID = Convert.ToInt32(grvXuatXu.DataKeys[e.RowIndex].Value) });
            Functions.Alert("Xóa bản ghi thành công", Request.Url.ToString());
        }

        protected void grvXuatXu_SelectedIndexChanged(object sender, EventArgs e)
        {
            int XuatXuID = int.Parse(grvXuatXu.DataKeys[grvXuatXu.SelectedIndex].Value.ToString());
            Response.Redirect("Default.aspx?Page=ProductOrigin&OID=" + XuatXuID);
        }

        protected void grvXuatXu_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grvXuatXu.PageIndex = e.NewPageIndex;
            grvXuatXuDataSource();
        }

        private void grvXuatXuDataSource()
        {
            grvXuatXu.DataSource = new cmsXuatXuBL().SelectAll();
            grvXuatXu.DataBind();
        }
 
    }
}